package scalaLearning.scalaBasic

import scala.actors.Actor

/*
给Actor发送case class的消息  发送类过去,必须是case类 专门用于模式匹配的类
 */
case class Register(username: String, password:String)//默认的构造器
case class Login(username: String , password:String)//默认的构造器

class UserManagerActor extends Actor{
  def act{
    while (true){
      receive{
        case Login(username, password) => println("login: " + username + ": " + password)
        case Register(username, password) => println("register: " + username + ": " + password)
      }
    }
  }
}

object UserManagerActor{
  def main(args: Array[String]) {
    val userActor = new UserManagerActor
    userActor.start()
    userActor ! Register("yasaka", "123")
    userActor ! Login("yasaka", "123")
  }
}